from rest_framework_extensions.cache.mixins import CacheResponseMixin
from rest_framework.generics import ListAPIView


from .models import Area
from .serializers import AreasSerializer

# Create your views here.


class AreasView(CacheResponseMixin,ListAPIView):

    serializer_class = AreasSerializer
    queryset = Area.objects.filter(parent=None)


class AreasSetView(CacheResponseMixin,ListAPIView):

    serializer_class = AreasSerializer

    # queryset = Area.objects.
    # def get(self,request,pk):
    #
    #     area = Area.objects.filter(parent=pk)[0]
    #
    #     return Response({'data':area})


    def get_queryset(self):

        num = self.kwargs['pk']

        return Area.objects.filter(parent=num)